<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="com.conversationboard.config.*" %>

<%@page pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>

<%@page import="com.conversationboard.controller.confirm.Confirm"%>

<%
	String key = Confirm.getKey(request.getUserPrincipal().getName());
%>

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title>User Info</title>
		<link rel="stylesheet" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>"/>
	</head>

	<body>
	
		<%= MainMenu.display(request.getUserPrincipal()) %>
	
		<div class="headingblock">
			<h1>User Info</h1>
		</div>

		<div class="mainblock">

			<c:if test="${user == null}">
				<p class='red'><strong>User does not exist in the database.</strong></p>
			</c:if>

			<div class="formsectionlight">			
				<table class="table">
					<tr class="row">
						<td class="header">Login ID</td>
						<td class="cell">${user.loginId}</td>
					</tr>
	
					<tr class="row">
						<td class="header">Display Name</td>
						<td class="cell">${user.fullDisplayName}</td>
					</tr>
	
					<tr class="row">
						<td class="header">Timezone</td>
						<td class="cell">${user.preferences.timeZoneString}</td>
					</tr>
	
					<c:if test="${siteAdmin}">	
						<tr class="row">
							<td class="header">Registration Date</td>
							<td class="cell">${user.creationDateString} (${user.creationDate})</td>
						</tr>
					
						<tr class="row">
							<td class="header">Last Accessed</td>
							<td class="cell">${user.lastAccessedString} (${user.lastAccessed})</td>
						</tr>
	
						<tr class="row">
							<td class="header"># Logins</td>
							<td class="cell"><fmt:formatNumber>${user.loginCount}</fmt:formatNumber></td>
						</tr>
	
						<tr class="row">
							<td class="header"># Posts</td>
							<td class="cell"><fmt:formatNumber>${user.postCount}</fmt:formatNumber></td>
						</tr>
	
						<tr class="row">
							<td class="header"># Times Banned</td>
							<td class="cell">${user.banCount}</td>
						</tr>
						
						<% if (Configuration.getInstance().isSupportSuggestBan()) { %>	
						<tr class="row">
							<td class="header"><a title="Who has suggest this user be banned?" href="<%= Configuration.getInstance().getRoot() %>/Pages/Admin/Reports/ban-requests-report.jsp?loginId=${user.loginId}"># Flagged Posts</a></td>
							<td class="cell">${user.suggestBans}</td>
						</tr>
						<% } %>
	
						<tr class="row">
							<td class="header">IP Address</td>
							<td class="cell">${user.ipAddress}</td>
						</tr>
	
						<tr class="row">
							<td class="header">Location</td>
							<td class="cell">${user.location}</td>
						</tr>
	
						<tr class="row">
							<td class="header">Host Name</td>
							<td class="cell">${user.hostName}</td>
						</tr>
					</c:if>
					
				</table>
		
				<br />
				
				<c:if test="${siteAdmin}">				
					<div class="formsection">				
						<p><a href="<%= Configuration.getInstance().getRoot() %>/Pages/Admin/Reports/yellowcard-report.jsp?loginId=${user.loginId}">See Historical Yellow Card Information for this user</a></p>
						<p><a href="<%= Configuration.getInstance().getRoot() %>/Pages/Admin/Reports/suggest-bans.jsp?loginId=${user.loginId}">Who has this user flagged posts by?</a></p>
						<p><a href="<%= Configuration.getInstance().getRoot() %>/FullTextSearchControllerServlet?terms=${user.loginId}&offset=0&searchtype=id&startdate=&enddate=&artefact=messages&idtype=loginid&sortorder=Descending&boardid=0">See this user's recent posts</a></p>
						<p><a href='<%= Configuration.getInstance().getRoot()%>/Admin/AdminCloneUsersControllerServlet?userid=${user.loginId}'>Look for Same User's Alternate Logins</a></p>
						<c:if test="${not user.permanent}"><p><a href="<%=Configuration.getInstance().getRoot()%>/Pages/Admin/confirm.jsp?action=setuserpermanent&loginId=${user.loginId}">Make User Permanent</a> (Ensure this user is not deleted when old users are removed automatically from the database)</p></c:if>
					</div>
				</c:if>
				
				<br />
				
				<c:if test="${siteAdmin}">
					<form class="formsection" action="<%= Configuration.getInstance().getRoot() %>/Admin/AdminGetIPsForUserControllerServlet" method="post">
						
						<p>Please use this option lightly, since it does a lot of work with the database.</p>
						
						<input name='loginId' value="${user.loginId}" type='hidden' />
						<input name='days' value="30" type='hidden' />
						<%= key %>						
						<input type='submit' value='     Get Distinct IPs for user in last 30 days    ' />
						
					</form>			
				</c:if>

				
				<br />
				
			</div>

		</div>

		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 

	</body>
	
</html>
